<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Photo extends CI_Controller {

	function __construct(){
		parent::__construct();
		$this->load->model('production_model');
		$this->load->model('toolimage_model');
	}
	public function show()
	{
		$pid = (int)$this->uri->segment(3);
		if(!$pid) show_404();

		$p = $this->production_model->get_production_byid($pid);
		if(!$p) show_error('该商品可能已经被删除');
		$data['p'] = $p;

		$current = $this->uri->segment(4,'big');
		$photos = json_decode($p->production_image);
		array_push($photos,$p->image);
		$data['photos'] = $photos;
		if($current == 'big'){
			$data['photo'] = $p->image;
		}else{
			$current = (int)$current ? (int)$current : 0;
			$data['photo'] = $photos[$current];
		}
		$this->load->view('photo.tpl',$data);
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */